Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@expressive-code/plugin-shiki
Advanced tools
Shiki syntax highlighting plugin for Expressive Code, a text marking & annotation engine for presenting source code on the web.
A default plugin of Expressive Code, an engine for presenting source code on the web.
It performs syntax highlighting of your code blocks using the popular Shiki highlighter, which is also being used by VS Code.
This plugin is installed by default by our higher-level packages like remark-expressive-code
, so it will be used automatically when rendering code blocks in your markdown / MDX documents.
No installation is required. This package is installed by default by our higher-level packages.
If you are using the core package directly (e.g. because you are writing an integration), see the Advanced use cases section for more information.
This plugin will automatically highlight your code blocks using the current theme of Expressive Code.
You only need to ensure that your opening code fences have a language identifier, e.g. js
for JavaScript:
```js
console.log('This code will be syntax highlighted!')
```
The full list of languages can be found in the Shiki documentation.
This plugin does not have any configuration options. It automatically uses the current theme of Expressive Code, which you can select using its theme
configuration option.
Here are configuration examples on how to select a theme in some popular site generators:
We assume that you're using our Astro integration astro-expressive-code
.
In your Astro config file, you can pass options to the plugin like this:
// astro.config.mjs
import { defineConfig } from 'astro/config'
import astroExpressiveCode from 'astro-expressive-code'
/** @type {import('astro-expressive-code').AstroExpressiveCodeOptions} */
const astroExpressiveCodeOptions = {
// You can set this to any of the themes bundled with Shiki,
// specify a path to JSON theme file, or pass an instance
// of the `ExpressiveCodeTheme` class here:
theme: 'dracula',
}
export default defineConfig({
integrations: [
astroExpressiveCode(astroExpressiveCodeOptions),
],
})
@next/mdx
// next.config.mjs
import createMDX from '@next/mdx'
import remarkExpressiveCode from 'remark-expressive-code'
/** @type {import('remark-expressive-code').RemarkExpressiveCodeOptions} */
const remarkExpressiveCodeOptions = {
// You can set this to any of the themes bundled with Shiki,
// specify a path to JSON theme file, or pass an instance
// of the `ExpressiveCodeTheme` class here:
theme: 'nord',
}
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
}
const withMDX = createMDX({
extension: /\.mdx?$/,
options: {
remarkPlugins: [
// The nested array structure is required to pass options
// to a remark plugin
[remarkExpressiveCode, remarkExpressiveCodeOptions],
],
rehypePlugins: [],
},
})
export default withMDX(nextConfig)
You only need to install this plugin if you are using the core package @expressive-code/core
directly. In this case, you can install the plugin like this:
# Note: This is an advanced usage example!
# You normally don't need to install this package manually,
# it is installed by default by our higher-level packages.
npm install @expressive-code/plugin-shiki
Warning: This is an advanced usage example! You normally don't need to use the core package directly, or manually add this plugin to the configuration.
import { ExpressiveCodeEngine } from '@expressive-code/core'
import { pluginShiki } from '@expressive-code/plugin-shiki'
const ec = new ExpressiveCodeEngine({
plugins: [
pluginShiki(),
],
})
const renderResult = await ec.render({
code: 'const hello = "World!"',
language: 'js',
})
// If you were to render the returned AST to HTML now,
// the code would be syntax highlighted.
FAQs
Shiki syntax highlighting plugin for Expressive Code, a text marking & annotation engine for presenting source code on the web.
The npm package @expressive-code/plugin-shiki receives a total of 0 weekly downloads. As such, @expressive-code/plugin-shiki popularity was classified as not popular.
We found that @expressive-code/plugin-shiki demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.